package cn.ffcs.uec.view.component;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import lombok.Getter;
import lombok.Setter;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.IdSpace;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Div;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Messagebox;

import cn.ffcs.raptornuke.plugin.common.zk.util.ZkUtil;
import cn.ffcs.raptornuke.portal.kernel.xml.DocumentException;
import cn.ffcs.uec.outStaff.constant.UecOutStaffConstants;
import cn.ffcs.uec.recordsApproval.util.ApprovalUtil;
import cn.ffcs.uec.view.component.bean.LogDownNewListboxBean;
import cn.ffcs.uec.view.manager.LogDownManager;
import cn.ffcs.uec.view.manager.UecStaffAllManager;
import cn.ffcs.uec.view.model.LogDown;
import cn.ffcs.uec.view.model.UecStaffAll;
import cn.ffcs.uom.common.util.ApplicationContextUtil;
import cn.ffcs.uom.common.util.IPortletInfoProvider;
import cn.ffcs.uom.common.util.ListboxUtils;
import cn.ffcs.uom.common.util.PlatformUtil;
import cn.ffcs.uom.common.util.PubUtil;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.vo.NodeVo;

@Controller
@Scope("prototype")
public class LogDownNewListboxExt extends Div implements IdSpace {
	protected final Log log = LogFactory.getLog(this.getClass());
	private static final long serialVersionUID = -2212731640371254189L;

	/**
	 * 对应页面上的bean
	 */
	@Getter
	@Setter
	private LogDownNewListboxBean bean = new LogDownNewListboxBean();


	/**
	 * 外包人员虚拟对象
	 */
	private UecStaffAll uecStaffAll = new UecStaffAll();
	private String  labelcType = "";
	private String  labelhType = "";
	private String  labelzType = "";
	
	private LogDown logDown = new LogDown();

	private UecStaffAllManager uecStaffAllManager = (UecStaffAllManager) ApplicationContextUtil
			.getBean("uecStaffAllManager");
	
	private LogDownManager logDownManager = (LogDownManager) ApplicationContextUtil
			.getBean("logDownManager");
	

	@Getter
	@Setter
	private IPortletInfoProvider portletInfoProvider;

	public LogDownNewListboxExt() {
		Executions.createComponents(UecOutStaffConstants.LOG_DOWN_NEW_EXT_LISTBOX_ZUL, this, null);
		Components.wireVariables(this, bean);
		Components.addForwards(this, this, '$');

		//this.addForward("onSelectUecOutStaffInfoByGetOrgTree", this, "onSelectUecOutStaffInfoByGetOrgTreeResponse");

	}
	
	/**
	 * 初始化
	 * 
	 * @throws ParseException
	 * @throws InterruptedException 
	 * @throws WrongValueException 
	 */
	public void onCreate() throws InterruptedException, WrongValueException, ParseException {
		this.bindCombobox();
		this.binbBean();
	}

	/**
	 * 绑定combobox
	 */
	private void bindCombobox() {
		//初始化专业类别
		List<NodeVo> joinCategoryList = new ArrayList<NodeVo>();
			String[][] glbdef10 = { { "营销类", "营销类" }, { "技术类", "技术类" },
					{ "综合类", "综合类" }
					 };
			for (int i = 0; i < glbdef10.length; i++) {
				NodeVo nodeVo = new NodeVo();
				for (int j = 0; j < 1; j++) {
					nodeVo.setId(glbdef10[i][j]);
					nodeVo.setName(glbdef10[i][j + 1]);
				}
				joinCategoryList.add(nodeVo);
			}
			ListboxUtils.rendererForEdit(bean.getTalentname(), joinCategoryList);
			
			/**
			 * 是否组监
			 */
			List<NodeVo> issupervisorList = new ArrayList<NodeVo>();
				String[][] glbdef11 = { { "是", "是" }, { "否", "否" }};
				for (int i = 0; i < glbdef11.length; i++) {
					NodeVo nodeVo = new NodeVo();
					for (int j = 0; j < 1; j++) {
						nodeVo.setId(glbdef11[i][j]);
						nodeVo.setName(glbdef11[i][j + 1]);
					}
					issupervisorList.add(nodeVo);
				}
				ListboxUtils.rendererForEdit(bean.getIssupervisor(), issupervisorList);
			/**
			 * 所有子标签（产品类）	
			 */
				List<NodeVo> talentcLabelList = new ArrayList<NodeVo>();
				String[][] glbdef12 = { { "智能连接", "智能连接" }, { "智慧家庭", "智慧家庭" },
						{ "物联网", "物联网" }, { "互联网金融", "互联网金融" },
						{ "新兴ICT应用", "新兴ICT应用" },{"其他","其他"} };
				for (int i = 0; i < glbdef12.length; i++) {
					NodeVo nodeVo = new NodeVo();
					for (int j = 0; j < 1; j++) {
						nodeVo.setId(glbdef12[i][j]);
						nodeVo.setName(glbdef12[i][j + 1]);
					}
					talentcLabelList.add(nodeVo);
				}
				ListboxUtils.rendererForEdit(bean.getTalentChanPin(), talentcLabelList);
				/**
				  * 行业类
				 */
				List<NodeVo> talenthLabelList = new ArrayList<NodeVo>();
				String[][] glbdef13 = { { "政务", "政务" }, { "军民融合", "军民融合" },
						{ "金融", "金融" }, { "工业企业", "工业企业" },
						{ "互联网", "互联网" },{"商客","商客"},{"教育","教育"},{"现代农业","现代农业"},
						{"交通物流","交通物流"},{"医卫","医卫"},{"其他","其他"}};
				for (int k = 0; k < glbdef13.length; k++) {
					NodeVo nodeVo = new NodeVo();
					for (int j = 0; j < 1; j++) {
						nodeVo.setId(glbdef13[k][j]);
						nodeVo.setName(glbdef13[k][j + 1]);
					}
					talenthLabelList.add(nodeVo);
				}
				ListboxUtils.rendererForEdit(bean.getTalentHangYe(), talenthLabelList);
				/**
				  * 综合类
				 */
			/*List<NodeVo> talentzLabelList = new ArrayList<NodeVo>();
				String[][] glbdef14 = { { "战力运营", "战力运营" }, { "人力资源", "人力资源" },
						{ "法律", "法律" }, { "财务管理", "财务管理" },
						{ "党群工会", "党群工会" },{ "风险管理", "风险管理" },
						{ "行政后勤", "行政后勤" }};
				for (int i = 0; i < glbdef14.length; i++) {
					NodeVo nodeVo1 = new NodeVo();
					for (int j = 0; j < 1; j++) {
						nodeVo1.setId(glbdef14[i][j]);
						nodeVo1.setName(glbdef14[i][j + 1]);
					}
					talentzLabelList.add(nodeVo1);
				}
				ListboxUtils.rendererForEdit(bean.getTalentzLabel(), talentzLabelList);*/
				
				/**
				 * 申报类型（实操/非实操/无）
				 */
				List<NodeVo> talentType = new ArrayList<NodeVo>();
				String[][] glbdef15 = {{ "无", "无" }, { "实操", "实操" }, { "非实操", "非实操" },
						};
				for (int i = 0; i < glbdef15.length; i++) {
					NodeVo nodeVo1 = new NodeVo();
					for (int j = 0; j < 1; j++) {
						nodeVo1.setId(glbdef15[i][j]);
						nodeVo1.setName(glbdef15[i][j + 1]);
					}
					talentType.add(nodeVo1);
				}
				ListboxUtils.rendererForEdit(bean.getTalentType(), talentType);
			}				
	/**
	 * 监听专业类别，带出子专业
	 * @throws ParseException 
	 * @throws com.itextpdf.text.DocumentException 
	 * @throws IOException 
	 * @throws DocumentException 
	 */
	public void onSelect$talentname() throws DocumentException, IOException, com.itextpdf.text.DocumentException, ParseException {
		//获取专业类别
		String talentCategory = (String)bean.getTalentname().getSelectedItem().getValue();
		/**
		 * 子专业
		 */
			List<NodeVo> childCategoryList = new ArrayList<NodeVo>();	
		if("营销类".equals(talentCategory)) {
			String[][] glbdef11 = { { "营销综合", "营销综合" }, { "营销策划域拓展", "营销策划域拓展" },
					{ "渠道管理", "渠道管理" }, { "业务管理", "业务管理" },
					{ "生态化产品运营", "生态化产品运营" },{"客户服务","客户服务"} };
			for (int i = 0; i < glbdef11.length; i++) {
				NodeVo nodeVo = new NodeVo();
				for (int j = 0; j < 1; j++) {
					nodeVo.setId(glbdef11[i][j]);
					nodeVo.setName(glbdef11[i][j + 1]);
				}
				childCategoryList.add(nodeVo);
			}
			ListboxUtils.rendererForEdit(bean.getChildtalentname(), childCategoryList);
		}	
		if("技术类".equals(talentCategory)) {
			String[][] glbdef11 = { { "大数据", "大数据" }, { "ICT", "ICT" },
					{ "云计算", "云计算" }, { "业务平台", "业务平台" },
					{ "核心网", "核心网" },{"光传输","光传输"},{"光接入","光接入"},{"IP","IP"},
					{"网络与信息安全","网络与信息安全"},{"卫星","卫星"},{"无线与移动","无线与移动"}, 
					{"电源与基础设施","电源与基础设施"} ,{"终端","终端"},{"IT","IT"},{"综合技术","综合技术"}  };
			for (int i = 0; i < glbdef11.length; i++) {
				NodeVo nodeVo = new NodeVo();
				for (int j = 0; j < 1; j++) {
					nodeVo.setId(glbdef11[i][j]);
					nodeVo.setName(glbdef11[i][j + 1]);
				}
				childCategoryList.add(nodeVo);
			}
			ListboxUtils.rendererForEdit(bean.getChildtalentname(), childCategoryList);
		}	
		if("综合类".equals(talentCategory)) {
			String[][] glbdef11 = { { "战力运营", "战力运营" }, { "人力资源", "人力资源" },
					{ "法律", "法律" }, { "财务管理", "财务管理" },
					{ "党群工会", "党群工会" },{ "风险管理", "风险管理" },
					{ "行政后勤", "行政后勤" }};
			for (int i = 0; i < glbdef11.length; i++) {
				NodeVo nodeVo = new NodeVo();
				for (int j = 0; j < 1; j++) {
					nodeVo.setId(glbdef11[i][j]);
					nodeVo.setName(glbdef11[i][j + 1]);
				}
				childCategoryList.add(nodeVo);
			}
			ListboxUtils.rendererForEdit(bean.getChildtalentname(), childCategoryList);
		}	
		/**
		 * 专家等级
		 */
		List<NodeVo> talentGrade = new ArrayList<NodeVo>();
		if("综合类".equals(talentCategory)) {
			String[][] glbdef11 = { { "C/D级", "C/D级" } };
			for (int i = 0; i < glbdef11.length; i++) {
				NodeVo nodeVo = new NodeVo();
				for (int j = 0; j < 1; j++) {
					nodeVo.setId(glbdef11[i][j]);
					nodeVo.setName(glbdef11[i][j + 1]);
				}
				talentGrade.add(nodeVo);
			}
			ListboxUtils.rendererForEdit(bean.getTalentgrade(), talentGrade);
		}else {
			String[][] glbdef11 = { { "C级", "C级" },{ "D级", "D级" } };
			for (int i = 0; i < glbdef11.length; i++) {
				NodeVo nodeVo = new NodeVo();
				for (int j = 0; j < 1; j++) {
					nodeVo.setId(glbdef11[i][j]);
					nodeVo.setName(glbdef11[i][j + 1]);
				}
				talentGrade.add(nodeVo);
			}
			ListboxUtils.rendererForEdit(bean.getTalentgrade(), talentGrade);
		}	
		
		
			
	}
	/**
	 * @throws ParseException 
	 * @throws WrongValueException 
	 * 获取全局变量，绑定数据导页面
	 * @Title: binbBean   
	 * @Description: TODO 
	 * @param: @throws InterruptedException      
	 * @return: void      
	 * @throws
	 */
	private void binbBean() throws InterruptedException, WrongValueException, ParseException{
		if (StrUtil.isNullOrEmpty(PlatformUtil.getCurrentUser())) {
			ZkUtil.showError("当前登录用户不存在!", "错误提示");
			return;
		} else {
			String screenName = PlatformUtil.getCurrentUser().getScreenName();
			if("n".equals(screenName.substring(0,1).toLowerCase())) {
				screenName=screenName.substring(1);
			}
			uecStaffAll.setCode(screenName.toUpperCase());
			uecStaffAll = uecStaffAllManager.findUecStaffAll(uecStaffAll);
			////////结束
			logDown.setCode(uecStaffAll.getCode());
		    logDown = logDownManager.findLogDownByLogDown(logDown);
		    if(logDown != null) {
		    	logDown.setJoinworkdate(uecStaffAll.getJoinworkdate());
		    	/**
				 * 用于随时控制个人信息维护项按钮开关
				 */
				String talentSwitch = ApprovalUtil.getTalentSwitch();
				if("open".equals(talentSwitch)) {
					bean.getSaveButton().setVisible(true);
					//利用开关设置是否已经填写完信息且提交，提交之后，所有信息不可修改
			    	if("N".equals(logDown.getOpenswitch())) {
			    		//bean.getSubmitButton().setVisible(true);
			    		bean.getSaveButton().setVisible(true);
			    		//bean.getYetSubmitButton().setVisible(false);
			    	}else {
			    		//bean.getSubmitButton().setVisible(false);
			    		bean.getSaveButton().setVisible(false);
			    		//bean.getYetSubmitButton().setVisible(true);
			    	}
				}else {
					bean.getSaveButton().setVisible(false);
				}
		    	
		    	PubUtil.fillBeanFromPo(logDown, bean);
		    	bean.getJoinworkdate().setValue(StrTraslateToDate(uecStaffAll.getJoinworkdate()));
		    	//bean.getTalentcLabel().setContext(logDown.getTalentcLabel());
		    	//bean.getTalenthLabel().setContext(logDown.getTalenthLabel());
		    	//bean.getTalentzLabel().setContext(logDown.getTalentzLabel());
		    }
		}
	}


	/**
	 * 重置
	 * 
	 * @throws Exception
	 */
	public void onReset() throws Exception {
	//	clearVariable();
		bean.getOutStaffCode().setValue(null);
		bean.getOutStaffName().setValue(null);
		bean.getOutStaffIdNum().setValue(null);
		PubUtil.clearComponent(this);
		Events.postEvent(UecOutStaffConstants.ON_CLEAN_TAB_UEC_OUT_STAFF_INFO_QUERY, this, null);
	}



	

	/**
	 * 按钮设置
	 * 
	 * @param canAdd
	 * @param candel
	 */
	public void setUecStaffButtonValid(boolean canAdd, boolean canEdit, boolean canDel) {
		bean.getAddOutStaffButton().setDisabled(!canAdd);
		bean.getEditOutStaffButton().setDisabled(!canEdit);
		bean.getDelOutStaffButton().setDisabled(!canDel);
	}
	/**
	 * 保存
	 * 
	 * @throws Exception
	 */
	public void onOk() throws Exception {
		
		String msg = this.checkUacStaffData();
		if (null != msg) {
			Messagebox.show(msg);
			return;
		}
		logDown = logDownManager.findLogDownByLogDown(logDown);
		if(logDown != null) {
			if(!"N".equals(logDown.getOpenswitch())) {
				Messagebox.show("您已报名，不可以再次进行信息维护，具体信息请联系人力资源部负责人!");
				return;
			}
			logDown.setLabelChanPinType(labelcType);
			logDown.setLabelHangYeType(labelhType);
			logDown.setLabelZongHeType(labelzType);
			String talentcLabel ="";
			String talenthLabel ="";
			String talentzLabel ="";
			if(!StrUtil.isNullOrEmpty(bean.getTalentChanPin().getSelectedCount()>0)) {
				Set test= bean.getTalentChanPin().getSelectedItems();
				Iterator it = test.iterator();  
				while (it.hasNext()) {  
					Listitem selectedItem = (Listitem)it.next(); 
					String tenpStr=(String)selectedItem.getValue();
					if(!StrUtil.isNullOrEmpty(tenpStr)) {
						talentcLabel=talentcLabel+tenpStr+"、";
					}
				} 
				if(!StrUtil.isNullOrEmpty(talentcLabel)) {
					talentcLabel=talentcLabel.substring(0,talentcLabel.lastIndexOf("、"));
					logDown.setTalentChanPin(talentcLabel);
				}
			}
			
			if(!StrUtil.isNullOrEmpty(bean.getTalentHangYe().getSelectedCount()>0)) {
				Set test= bean.getTalentHangYe().getSelectedItems();
				Iterator it = test.iterator();  
				while (it.hasNext()) {  
					Listitem selectedItem = (Listitem)it.next(); 
					String tenpStr=(String)selectedItem.getValue();
					if(!StrUtil.isNullOrEmpty(tenpStr)) {
						talenthLabel=talenthLabel+tenpStr+"、";
					}
				} 
				if(!StrUtil.isNullOrEmpty(talenthLabel)) {
					talenthLabel=talenthLabel.substring(0,talenthLabel.lastIndexOf("、"));
					logDown.setTalentHangYe(talenthLabel);
				}
			}
			
			/*if(!StrUtil.isNullOrEmpty(bean.getTalentzLabel().getSelectedCount()>0)) {
				Set test= bean.getTalentzLabel().getSelectedItems();
				Iterator it = test.iterator();  
				while (it.hasNext()) {  
					Listitem selectedItem = (Listitem)it.next(); 
					String tenpStr=(String)selectedItem.getValue();
					if(!StrUtil.isNullOrEmpty(tenpStr)) {
						talentzLabel=talentzLabel+tenpStr+"、";
					}
				} 
				if(!StrUtil.isNullOrEmpty(talentzLabel)) {
					talentzLabel=talentzLabel.substring(0,talentzLabel.lastIndexOf("、"));
				}
				logDown.setTalentzLabel(talentzLabel);
			}*/
			logDown.setTalentname((String)bean.getTalentname().getSelectedItem().getValue());
			logDown.setChildtalentname((String)bean.getChildtalentname().getSelectedItem().getValue());
			logDown.setBegindatetanlent(bean.getBegindatetanlent().getValue());
			logDown.setBegindatechild(bean.getBegindatechild().getValue());
			logDown.setIssupervisor((String)bean.getIssupervisor().getSelectedItem().getValue());
			//logDown.setTalentgrade((String)bean.getTalentHangYe().getSelectedItem().getValue());
			logDown.setTalentType((String)bean.getTalentType().getSelectedItem().getValue());
			logDown.setTalentgrade((String)bean.getTalentgrade().getSelectedItem().getValue());
			logDown.updateOnly();
			Messagebox.show("数据保存成功");
			this.onCreate();
		}else {
			Messagebox.show("数据保存失败");
			this.onCreate();
		}

	}
	/**
	 * 检测填入的参数是否为空
	 * @throws ParseException 
	 */
	private String checkUacStaffData() throws ParseException {
		if (StrUtil.isNullOrEmpty(bean.getTalentname().getSelectedItem())) {
			return "请选择申报专业";
		} else if (StrUtil.isNullOrEmpty(bean.getChildtalentname().getSelectedItem())) {
			return "请选择子专业";
		} else if (StrUtil.isNullOrEmpty(bean.getBegindatetanlent().getValue())) {
			return "参加此专家类别日期不可为空";
		}  else if (StrUtil.isNullOrEmpty(bean.getBegindatechild().getValue())) {
			return "参加子专业日期不可为空";
	}  else if (StrUtil.isNullOrEmpty(bean.getIssupervisor().getSelectedItem())) {
		    return "是否组监不可为空";
	}else if (StrUtil.isNullOrEmpty(bean.getTalentType().getSelectedItem())) {
	    return "申报类型不可为空";
    }else if(StrUtil.isNullOrEmpty(bean.getTalentgrade().getSelectedItem())) {
		return "专家等级不可为空";
	}else if(!StrUtil.isNullOrEmpty(bean.getBegindatetanlent().getValue())) {
		String strTraslateFormat = StrTraslate(bean.getBegindatetanlent().getValue());
		int tempCount=0;
		if(!StrUtil.isNullOrEmpty(uecStaffAll.getJoinworkdate())) {
			String joinworkdate = uecStaffAll.getJoinworkdate();
			tempCount=compare_date(strTraslateFormat,joinworkdate);
			if(tempCount<0) {
				return "从事所选申报专业工作起始日期小于参加工作日期";
			}
		}else {
			return "系统里参加工作日期为空，请找人力管理员进行维护";
		}
	}
		String strTraslateFormat = StrTraslate(bean.getBegindatechild().getValue());
		String strTraslateFormat1 = StrTraslate(bean.getBegindatetanlent().getValue());
		int compare_date = compare_date(strTraslateFormat,strTraslateFormat1);
		if(compare_date<0) {
			return "从事子专业起始日期不得小于从事所选申报专业工作起始日期";
		}
		
		
		/* else if (StrUtil.isNullOrEmpty(bean.getTalentcLabel().getSelectedItem())) {
		return "是否组监不可为空";
	}  else if (StrUtil.isNullOrEmpty(bean.getTalenthLabel().getSelectedItem())) {
	   return "是否组监不可为空";
}  else if (StrUtil.isNullOrEmpty(bean.getTalentzLabel().getSelectedItem())) {
	return "是否组监不可为空";
} */
		
		return null;
	}
	
	 public Date StrTraslateToDate(String data) throws ParseException {
		 SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
		 data=data.replace("/", "-");
		 Date newDate = df.parse(data);
		 //data=df.format(newDate);
		 System.out.println("logDown信息维护中，日期转换--------------"+newDate);
		 return newDate;
	 }
	 /**
	  * 比较两个字符串时间大小
	  * @param DATE1
	  * @param DATE2
	  * @return
	  */
	 public static int compare_date(String DATE1, String DATE2) {
		 int temp=0;//0相等;-1 前小于后;1前大于后  
		
		 DATE1=DATE1.replace("/", "-");
		 DATE2=DATE2.replace("/", "-");
		
		 DATE1= traslateStringFormat(DATE1);
		 DATE2= traslateStringFormat(DATE2);
	       try {
	    	   temp = DATE1.compareTo(DATE2);
	      } catch (Exception exception) {
	         exception.printStackTrace();
	      }
	      return temp;
	}
	 /**
	  * date  转 String
	  * @param data
	  * @return
	  * @throws ParseException
	  */
	 public String StrTraslate(Date data) throws ParseException {
		 SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
		 String newDate = df.format(data);
		 return newDate;
	 }
	 
	 public void initLogDown() {
		 try {
				if (StrUtil.isNullOrEmpty(PlatformUtil.getCurrentUser())) {
					ZkUtil.showError("当前登录用户不存在!", "错误提示");
					return;
				} else {
					logDown = new LogDown();
					String screenName = PlatformUtil.getCurrentUser().getScreenName();
					if("n".equals(screenName.substring(0,1).toLowerCase())) {
						screenName=screenName.substring(1);
						logDown.setStaffCatogery("合同制员工");
					}else {
						logDown.setStaffCatogery("外包员工");
					}
					uecStaffAll.setCode(screenName.toUpperCase());
					uecStaffAll = uecStaffAllManager.findUecStaffAll(uecStaffAll);
				}
				if (null == uecStaffAll) {
					Messagebox.show("人员信息获取失败！");
					return;
				}else {
					//保存数据到log_down  日志操作
					SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:MM:SS");
					logDown.setPkPsndoc(uecStaffAll.getPkpsndoc());
					boolean flag = getLogDown(logDown);//判断数据库里是否已经存在，以免初次登录重新添加
					if(!flag) {
					//logDown=new LogDown();
					logDown.setDowntime(df.format(new Date()));
					logDown.setPkPsndoc(uecStaffAll.getPkpsndoc());
					logDown.setName(uecStaffAll.getName());
					logDown.setCode(uecStaffAll.getCode());
					logDown.setBirthdate(uecStaffAll.getBIRTHDATE());
					logDown.setDownflag("N");
					logDown.setSex(uecStaffAll.getSex());
					logDown.setEnterunittime(uecStaffAll.getEnterunittime());
					logDown.setJoinworkdate((!StrUtil.isNullOrEmpty(uecStaffAll.getJoinworkdate())?uecStaffAll.getJoinworkdate():""));
					logDown.setPartyName((!StrUtil.isNullOrEmpty(uecStaffAll.getPartyname())?uecStaffAll.getPartyname():""));
					logDown.setOpenswitch("N");
					logDown.setCreatetime(df.format(new Date()));
					logDown.setMobile((!StrUtil.isNullOrEmpty(uecStaffAll.getMobile())?uecStaffAll.getMobile():""));
					logDown.setEmail((!StrUtil.isNullOrEmpty(uecStaffAll.getEmail())?uecStaffAll.getEmail():""));
					logDown.setWorkforg((!StrUtil.isNullOrEmpty(uecStaffAll.getForgname())?uecStaffAll.getForgname():""));
					logDown.setWorkorg((!StrUtil.isNullOrEmpty(uecStaffAll.getOrgname())?uecStaffAll.getOrgname():""));
					logDown.addOnly();
					}
				}
			} catch (Exception e) {			
				e.printStackTrace();
			} 
		 
	 }
	 public boolean getLogDown(LogDown logdown) throws ParseException {
		 boolean flag=false;
		 LogDown findLogDownByLogDown = logDownManager.findLogDownByLogDown(logdown);
		 if(findLogDownByLogDown!=null) {
			 flag=true;
			 logDown=findLogDownByLogDown;
		 }
		 return flag;
	 }
	 
	 public static String traslateStringFormat(String DATE1) {
		 int aa=DATE1.indexOf("-");
		 int bb=DATE1.lastIndexOf("-");
		 String ff =DATE1.substring(bb+1);
		 if(bb-aa<3) {
			 if(ff.length()<2) {
				 DATE1=DATE1.substring(0,5)+"0"+DATE1.substring(aa+1,bb)+
						 "-0"+DATE1.substring(bb+1);
				 
			 }else {
				 DATE1=DATE1.substring(0,5)+"0"+DATE1.substring(aa+1,bb)+DATE1.substring(bb);
			 }
		 }
		 if(ff.length()<2) {
			 DATE1=DATE1.substring(0,bb+1)+"0"+DATE1.substring(bb+1);
		 }
		 return DATE1;
	 }
}
